﻿<UserControl x:Class="StockholmsStad.Windows.UI.Modules.Minister.Controls.MinisterDetailsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:StockholmsStad.Windows.UI.Modules.Minister.Controls"
    xmlns:customControls="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Controls;assembly=StockholmsStad.Windows.UI.Infrastructure"
    xmlns:Converters="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Converters;assembly=StockholmsStad.Windows.UI.Infrastructure">
    <UserControl.Resources>
        <Converters:PersonalNumberConverter x:Key="personalNumberConverter" />
    </UserControl.Resources>

    <Grid HorizontalAlignment="Stretch">

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Margin="5,10,15,5" HorizontalAlignment="Stretch"  Grid.Column="0" Grid.Row="0" Grid.RowSpan="3">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Label x:Name="lblAppointed" Content="Förordnade:" Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" />

            <Grid Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,0,0,20">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <customControls:DateTimePicker Grid.Column="0" x:Name="dcAssignmentStartDate" SelectedDate="{Binding AssignmentStartDate, Mode=TwoWay}" />
                <Polyline Grid.Column="1" Points="0,20 0,20 10,0" Stroke="Gray" StrokeThickness="1" Margin="4,0,4,0" />
                <customControls:DateTimePicker Grid.Column="2" x:Name="dcAssignmentEndDate" SelectedDate="{Binding AssignmentEndDate, Mode=TwoWay}" />
                <CheckBox Grid.Column="3" x:Name="cbSpecial" Content="Särskilt" Padding="5,0,5,0" Margin="10,0,0,0" 
                              IsChecked="{Binding SpecialAssignment}" VerticalAlignment="Center" />
            </Grid>

            <Label Content="Förrättarkod:" Grid.Row="1" Grid.Column="0" />
            <TextBox x:Name="MinisterCodeTextBox" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Width="100"
                         Text="{Binding MinisterCode, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="50" />

            <Label Content="Personnummer:" Grid.Row="2" Grid.Column="0" />
            <Label Content="Förnamn:" Grid.Row="3" Grid.Column="0" />
            <Label Content="Efternamn:" Grid.Row="4" Grid.Column="0" />
            <Label Content="C/o-adress:" Grid.Row="5" Grid.Column="0" />
            <Label Content="Adress:" Grid.Row="6" Grid.Column="0" />
            <Label Content="Postnummer:" Grid.Row="7" Grid.Column="0" />
            <Label Content="PostOrt:" Grid.Row="8" Grid.Column="0" />
            <Label Content="Land:" Grid.Row="9" Grid.Column="0" />
            <Label Content="Epost:" Grid.Row="10" Grid.Column="0" />
            <Label Content="Telefon:" Grid.Row="11" Grid.Column="0" />
            <Label Content="Mobil:" Grid.Row="12" Grid.Column="0" />
            <Label Content="Notering:" Grid.Row="13" Grid.Column="0" VerticalAlignment="Top" />

            <TextBox x:Name="BirthdayNumberTextBox" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" MaxLength="13" Width="100"
                         Text="{Binding BirthdayNumber, Converter={StaticResource personalNumberConverter}, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" />


            <TextBox x:Name="FirstNamesTextBox" Grid.Row="3" Grid.Column="1"
                         Text="{Binding FirstName, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="200" MaxWidth="350" />

            <TextBox x:Name="LastNameTextBox" Grid.Row="4" Grid.Column="1" 
                         Text="{Binding LastName, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="70" MaxWidth="350" />

            <TextBox x:Name="CoAddressTextBox" Grid.Row="5" Grid.Column="1" 
                         Text="{Binding CoAddress, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="150" MaxWidth="350" />

            <TextBox x:Name="StreetAddressTextBox"  Grid.Row="6" Grid.Column="1" 
                         Text="{Binding StreetAddress, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="150" MaxWidth="350" />

            <TextBox x:Name="ZipCodeTextBox"  Grid.Row="7" Grid.Column="1" 
                         Text="{Binding ZipCode, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="10" />

            <TextBox x:Name="CityTextBox"  Grid.Row="8" Grid.Column="1" 
                         Text="{Binding City, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="100" MaxWidth="350" />

            <TextBox x:Name="CountryTextBox"  Grid.Row="9" Grid.Column="1" 
                         Text="{Binding Country, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="50" MaxWidth="350" />

            <TextBox x:Name="EmailTextBox"  Grid.Row="10" Grid.Column="1" 
                     Text="{Binding Email, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                     Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="200" MaxWidth="350" />

            <TextBox x:Name="PhoneNumberTextBox"  Grid.Row="11" Grid.Column="1" 
                         Text="{Binding PhoneNumber, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                         Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="50" />

            <TextBox x:Name="CellPhoneTextBox"  Grid.Row="12" Grid.Column="1" 
                     Text="{Binding CellPhone, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                     Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="50" />

            <TextBox x:Name="NoteTextBox" Grid.Row="13" Grid.Column="1" AcceptsReturn="True" MinLines="4" Height="60" TextWrapping="Wrap"
                     Text="{Binding Note, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" 
                     Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" MaxLength="255" />

        </Grid>


        <GroupBox Grid.Column="1" Grid.Row="0" Header="Språk" Margin="0,10,5,5" Padding="5,10,5,5">
                
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="35" />
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <ComboBox x:Name="cbLanguages" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Path=Name}" />
                                </StackPanel>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>

                    <Label Content="Annat språk:" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" />
                    <TextBox x:Name="tbLanguage" Text="" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Stretch" />

                    <Button x:Name="btnLanguage" Content=">>" Grid.Row="0" Grid.Column="1" Width="25" Height="22"
                            HorizontalAlignment="Center" Margin="0,2,0,0" Click="btnLanguage_Click" />
                    <Button x:Name="btnDeleteLanguage" Content="&lt;&lt;" Grid.Row="1" Grid.Column="1" Width="25" Height="22"
                            HorizontalAlignment="Center" Margin="0,2,0,0" Click="btnDeleteLanguage_Click" />
                    <Button x:Name="btnOtherLanguage" Content=">>" Grid.Row="2" Grid.Column="1" Width="25" Height="22"
                            HorizontalAlignment="Center" Margin="0,2,0,0" Click="btnOtherLanguage_Click" />
                    
                    <ListBox x:Name="lbLanguages" Grid.RowSpan="3" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 
                             ItemsSource="{Binding Languages}" SelectionChanged="lbLanguages_SelectionChanged">
                    </ListBox>
                </Grid>

            </GroupBox>

        <GroupBox Grid.Column="1" Grid.Row="1" Header="Tjänstgöring" Margin="0,10,5,5" Padding="5,10,5,5">
            <controls:MinisterServiceListControl />
        </GroupBox>
        
        <GroupBox Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" Header="Utskrift" Margin="0,10,5,5" Padding="5,10,5,5">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <TextBlock Text="Välj utskriftsalternativ:" Grid.Row="0" Margin="10, 0, 0, 10" />

                <StackPanel Orientation="Vertical" Grid.Row="1" Margin="10">
                    <RadioButton x:Name="RadioButtonPrintMinisterService" Content="Tjänstgöringslista" 
                         Margin="10, 0, 0, 10" GroupName="PrintCommands" IsChecked="True" />
                    <RadioButton x:Name="RadioButtonPrintReimbursement" Content="Arvode Länsstyrelse" 
                         Margin="10, 0, 0, 0" GroupName="PrintCommands" />
                </StackPanel>

                <StackPanel Orientation="Vertical" Grid.Row="2" Margin="10">
                    <TextBlock Text="Arvodesdatum från och med:" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" Margin="0,0,0,5" />
                    <customControls:DateTimePicker Grid.Row="2" Grid.Column="0" x:Name="dpDateFrom" Width="100" HorizontalAlignment="Left"/>
                </StackPanel>

                <StackPanel Orientation="Vertical" Grid.Row="3" Margin="10">
                    <TextBlock Text="Arvodesdatum till och med:" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" Margin="0,0,0,5" />
                    <customControls:DateTimePicker Grid.Row="3" Grid.Column="0" x:Name="dpDateTo" Width="100" HorizontalAlignment="Left"/>
                </StackPanel>

                <StackPanel Orientation="Horizontal" Grid.Row="4" Margin="10">
                    <Button x:Name="btnPrint" Content="Skriv ut" HorizontalAlignment="Left" Margin="2, 0, 0, 0" Click="btnPrint_Click" />
                </StackPanel>
            </Grid>

        </GroupBox>

        <StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,5,5">
                <Button x:Name="AddButton" Content="Lägg till ny" Width="70" />
                <Button x:Name="CancelButton" Content="Ångra" Click="CancelButton_Click" IsEnabled="False" Width="70" Margin="5,0,0,0" />
                <Button x:Name="SaveButton" Content="Spara" Command="{Binding SaveCommand}" Click="SaveButton_Click" Width="70" Margin="5,0,0,0" />
            </StackPanel>

    </Grid>

</UserControl>
